﻿@page "/datagrid/print"

@using Syncfusion.Blazor.Grids
@using BlazorDemos
@using blazor_griddata
@inherits SampleBaseComponent;

<SampleDescription>
    <p>This sample demonstrates the different options to print the hierarchy DataGrid.</p>
</SampleDescription>
<ActionDescription>
   <p>The DataGrid can be printed using the <code><a target='_blank' class='code' href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_Print'>Print</a></code> method. While printing, the pager and scrollbar will be removed if they are enabled in DataGrid. By default, all pages will be printed. We can print current page alone by setting the <code><a target='_blank' class='code' href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_PrintMode'>PrintMode</a></code> property value as <strong>CurrentPage</strong>. The childDataGrid allows us to print the DataGrid with the following options,</p>
   <ul>
        <li><strong>Expanded</strong> - Prints the master DataGrid with expanded child DataGrids.</li>
        <li><strong>All</strong> - Prints the master DataGrid with all the child DataGrids.</li>
         <li><strong>None</strong> - Prints the master DataGrid alone.</li>
    </ul>
    <p>We can change the child DataGrid's print option by using the <code><a target='_blank' class='code' href='https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_HierarchyPrintMode'>HierarchyPrintMode</a></code> property.</p>
     <p>More information on the print feature can be found in this <a target='_blank' href='https://blazor.syncfusion.com/documentation/grid/print/'>documentation section</a>.</p>
</ActionDescription>

<div class="col-lg-12 control-section">
    <div class="content-wrapper">
        <div class="row">
            <SfGrid DataSource="@GridData" AllowPaging="true" Toolbar="@(new List<string>() { "Print" })">
                <GridColumns>
                    <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right"  Width="120"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right"  Width="130"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right"  Width="120"></GridColumn>                   
                    <GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn>
                </GridColumns>
            </SfGrid>

        </div>
    </div>
</div>

@code{

    public List<OrdersDetails> GridData { get; set; }

    protected override void OnInitialized()
    {
        GridData = OrdersDetails.GetAllRecords();
    }
}
